package com.chs.recoginition.controller;


import com.chs.recoginition.pojo.GiveUp;
import com.chs.recoginition.service.IGiveUpService;
import com.chs.recoginition.vo.PageRespVo;
import com.chs.recoginition.vo.Result;
import com.chs.recoginition.vo.reqvo.GiveUpPageVo;
import com.chs.recoginition.vo.reqvo.IdentificationPageVo;
import com.chs.recoginition.vo.respVo.GiveUpRespVo;
import com.chs.recoginition.vo.respVo.ImageRecognitionRespVo;
import com.chs.recoginition.vo.respVo.UserRespVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 * @author CHS
 * @since 2023-04-10
 */
@RestController
@RequestMapping("/giveUp")
public class GiveUpController extends BaseController{
    @Resource
    private IGiveUpService giveUpService;

    /**
     * 分页查询
     * @param reqVo
     * @return
     */
    @PostMapping("/findPage")
    Result<PageRespVo<GiveUpRespVo>> findPage(@RequestBody GiveUpPageVo reqVo) {
        return Result.success(giveUpService.findPage(reqVo));
    }

    /**
     * 新增
     * @param reqVo
     * @return
     */
    @PostMapping("/save")
    Result<Void> save(@RequestBody GiveUp reqVo){
        UserRespVo user = getUser();
        giveUpService.save(reqVo, user);
        return Result.success();
    }

    /**
     * 删除
     * @param idList
     * @return
     */
    @PostMapping("/remove")
    Result<Void> remove(@RequestBody String idList){
        giveUpService.remove(idList);
        return Result.success();
    }


    /**
     * 查询该帖子当前用户是否已经点赞
     * @param invitationId
     * @return
     */
    @PostMapping("/getBoolean")
    Result<Boolean> getBoolean(@RequestBody Integer invitationId) {
        return Result.success(giveUpService.getBoolean(invitationId,getUser()));
    }

    /**
     * 点赞
     * @param invitationId
     */
    @PostMapping("/getParse")
    Result<Integer> getParse(@RequestBody Integer invitationId) {
        return Result.success(giveUpService.getParse(invitationId, getUser()));
    }

    /**
     * 获取当前分享的点赞数量
     * @param invitationId
     * @return
     */
    @PostMapping("/getSize")
    Result<Integer> getSize(@RequestBody Integer invitationId) {
        return Result.success(giveUpService.getSize(invitationId));
    }
 
}
